package org.jeecg.modules.interview.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.internship.entity.Internship;
import org.jeecg.modules.internship.entity.vo.QureyInternship;
import org.jeecg.modules.interview.entity.Interview;
import org.jeecg.modules.interview.service.InterviewService;
import org.jeecg.modules.upload.FileUploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liujiamiao
 * @since 2020-11-04
 */
@Validated
@RestController
@RequestMapping("/interview/interview")
@Api(tags = "面试情况接口")
public class InterviewController {

    @Autowired
    private InterviewService interviewService;


    @ApiOperation("保存")
    @PostMapping("/save")
    public Result save(@Valid @ApiParam("面试情况信息类") @RequestBody Interview interview){
        interviewService.saveOrUpdateEntity(interview);
        return Result.ok();
    }

    @ApiOperation("根据id获取信息")
    @GetMapping("/info/{id}")
    public Result info(@ApiParam("根据基本信息id获取") @PathVariable("id")Integer id){
        Interview info = interviewService.info(id);
        return Result.ok(info);
    }

    @ApiOperation("更新")
    @PutMapping("/update")
    public Result update(@ApiParam("面试情况信息类") @RequestBody Interview interview){
        interviewService.updateById(interview);
        return Result.ok();
    }

    @ApiOperation("上传word简历")
    @PostMapping("/upload")
    public Result uploadWord(@ApiParam("word简历文件") @RequestParam("file") MultipartFile upload) throws IOException {
        //返回地址
        String path = FileUploadUtils.upload(upload,"files");
        return Result.ok(path);
    }

}

